package com.xh.bussiness.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xh.bussiness.system.bean.dto.DictionaryTypeBean;
import com.xh.bussiness.system.bean.request.DictionaryTypeRequest;
import com.xh.bussiness.system.model.DictionaryType;
import com.xh.bussiness.system.dao.DictionaryTypeMapper;
import com.xh.bussiness.system.service.IDictionaryTypeService;
import com.xh.core.service.impl.BaseServiceImpl;
import org.springframework.stereotype.Service;
import com.xh.core.bean.XhPage;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author daiwei
 * @since 2018-10-17
 */
@Service
public class DictionaryTypeServiceImpl extends BaseServiceImpl<DictionaryTypeMapper, DictionaryType> implements IDictionaryTypeService {
    @Override
    public XhPage queryDictionaryTypePage(XhPage page, DictionaryTypeRequest bean) {
        QueryWrapper qw=new QueryWrapper<DictionaryType>();
        //拼装条件
        qw=prepareParams(bean, qw);

        return (XhPage) this.selectPage(page,qw,DictionaryTypeBean.class);
    }

    @Override
    public List queryDictionaryType(DictionaryTypeRequest bean) {
        QueryWrapper qw=new QueryWrapper<DictionaryType>();
        //拼装条件
        qw=prepareParams(bean, qw);

        return this.selectList(qw,DictionaryTypeBean.class);
    }


    /**
     * 准备条件
     * @param bean
     * @param qw
     */
    private QueryWrapper prepareParams(DictionaryTypeRequest bean, QueryWrapper qw) {
        if(bean.getIds()!=null&&bean.getIds().length>0){
            qw.in("id",bean.getIds());
        }
        return qw;
    }
}
